﻿using System;
using System.Collections.Generic;
using SQLDeployAnything.Data;
using System.ComponentModel;
using System.IO;

namespace SQLDeployAnything.Data.Helpers
{
    public class FileController :INotifyPropertyChanged
    {
        private List<Environment.Environment> mEnvironments;
        private string mConnectionFile;

        public string ConnectionFile
        {
            get { return mConnectionFile; }
            set
            {
                if (mConnectionFile != value)
                {
                    if (!File.Exists(value))
                    {
                        throw new FileNotFoundException("Connection File [" + value + "] was not found.");
                    }
                    //TODO change this.
                    mConnectionFile = value;
                }
            }
        }

        public List<Environment.Environment> Environments
        {
            get { return mEnvironments; }
            private set
            {
                mEnvironments = value;
                OnPropertyChanged("Environments");
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;
        protected internal void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(name));
        }
    
    }
}
